<template>

  <div class="list">
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoadList"
    >
      <div
        class="customer-list"
        v-for="(item,i) in dataSource"
        :key="i">
        <div>
          <div class="name">单据编号：{{item.receiptsNo || '无'}}</div>
          <div class="contact">
            <span>款项类型：{{ item.fundTypeName || '无' }}</span>
          </div>
          <div class="contact">
              <span>交易金额：
                <span style="color: lightseagreen" v-if="item.businessType == 2">-{{item.businessMoney}}</span>
                <span style="color: red" v-if="item.businessType == 1">+{{item.businessMoney}}</span>
              </span>
          </div>
          <div class="contact">
            <span>账户余额：{{ item.surplus || '无'}}</span>
          </div>
          <div class="contact">
            <span>日期：{{ item.createTime || '无'}}</span>
          </div>
          <div class="contact">
            <span>备注：{{ item.remark || '无'}}</span>
          </div>
        </div>
      </div>
    </van-list>
  </div>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {getAction} from "../../../../../../api/manage";

  export default {
    name: 'flowDetailsTab',
    mixins:[JeecgListMixin, mixinDevice],
    components: {

    },
    props: {
      record: {}
    },
    data () {
      return {
        description: '财务账户流水明细表管理页面',
        // 表头
        columns: [
          {
            title:'日期',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title:'款项类型',
            align:"center",
            dataIndex: 'fundTypeName'
          },
          {
            title:'单据编号',
            align:"center",
            dataIndex: 'receiptsNo'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark'
          },
          {
            title:'交易金额',
            align:"center",
            dataIndex: 'businessMoney',
            slots: { title: 'customTitle' },
            scopedSlots: { customRender: 'businessMoney' },
          },
          {
            title:'余额',
            align:"center",
            dataIndex: 'surplus'
          },
        ],
        url: {
          list: "/ghFinanceAccountFlowDetails/list",
          delete: "/ghFinanceAccountFlowDetails/delete",
        },
        dictOptions:{},
        finished: false,
      }
    },
    watch:{
      //监听record值的变化，变化则加载新的数据
      record:function(newVal,oldVal){
        //console.log(newVal +"---"+oldVal)
        this.loadData()
      },
    },
    created() {
      this.loadData()
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      //下一页
      onLoadList(){
        this.ipagination.current++
        this.loadData(this.ipagination.current)
      },
      loadData(arg) {
        if(!this.url.list){
          this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
          this.dataSource = [];
          this.finished = false;
        }
        this.loading = true;
        var params = this.getQueryParams();//查询条件
        params.accountId = this.record.id;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource = [...this.dataSource, ...res.result.records]
            if(res.result.total)
            {
              this.ipagination.total = res.result.total;
            }else{
              this.ipagination.total = 0;
            }
          }else{
            this.$message.warning(res.message)
          }
          if(res.result.records.length<10){
            this.finished = true;
          }
        }).finally(() => {
          this.loading = false
        })
      },
    }
  }
</script>
<style scoped lang="less">
  @import '~@assets/less/common.less';
  .select-pk{
    display:flex;
    align-items:center;
    margin:10px 0;
    &>span{
      font-weight: bold;
    }
    &-text{
      width: calc(100% - 6em);
      height: 30px;
      text-indent: 1em;
      line-height: 28px;
      border: 1px solid #d9d9d9;
      border-radius: 4px;
    }
  }
  .list{
    overflow-y: scroll;
    height:calc(100vh - 175px);
    margin-top: 10px;
  }
  ::-webkit-scrollbar {
    display: none;
  }
  .customer-list{
    /*display: flex;*/
    align-items: center;
    border-top: 1px solid #d9d9d9;
    .name{
      font-size: 13px;
      color: #161616;
      line-height: normal;
      margin-top: 5px;
    }
    .contact{
      margin-top: 5px;
      font-size: 12px;
      color: #a39f9f;
      margin-bottom: 5px;
    }
  }
</style>